#ifndef BLEND_MATH_H
#define BLEND_MATH_H
#include "tp_type.h"

#define PM_PI      3.14159265358979323846
#define PM_PI_2    1.57079632679489661923
#define PM_PI_4    0.78539816339744830962
#define PM_2_PI    6.28318530717958647692



#define SQRT_FUZZ (-1.0e-12)
//
#define IS_FUZZ(a,fuzz) (fabs(a) < (fuzz) ? 1 : 0)


#define Bl_Square(x) x*x
#define Bl_MIN(x,y)	((x)<(y)?(x):(y))
#define Bl_MAX(x,y)	((x)>(y)?(x):(y))


int blFindMin(float *d, int len);		//find minimun
int blFindMax(float *d, int len);		//find maximun
float blSqrt(float x);					//sqrt
float blSaturate(float x, float max);	//return large number between x and max
int blSatinplace(float * const x, float max);	//
int blClipMax(double * const x, double max);	//limit x < max

#endif